
local request_method = ngx.var.request_method
if "POST" == request_method then
    ngx.req.read_body()
    local data = ngx.req.get_body_data()
    if nil == data then
        local fname = ngx.req.get_body_file()
        if nil == fname then
            ngx.exit(406)
        end
        
        local fp,err = io.open(fname,"rb")
        if nil == fp then
            ngx.exit(500)
        end 
        data = fp:read "*a"
        fp:close()
    end
    if nil == data then
        ngx.exit(200)
    end

    if string.find(data, "userdict /setpagedevice undef") or 
       string.find(data, "currentdevice putdeviceprops") then
        nlog.warn("ghostscript filtered")
        ngx.exit(200)
    end
end